#! /usr/bin/env python3
#coding=utf-8
import pandas as pd
import rospy
from sensor_msgs.msg import LaserScan
import math
import matplotlib.pyplot as plt
import numpy as np
import threading
import time
def RAD2DEG(x):
    return x * 180.0/math.pi

def liadrCallback(msg):
    count = int(msg.scan_time / msg.time_increment)
    rospy.loginfo(f"angle_range, {RAD2DEG(msg.angle_min)},{RAD2DEG(msg.angle_max)}")
    for i in range(0,count,10):
        degree = float(RAD2DEG(msg.angle_min+msg.angle_increment * i))
        rospy.loginfo(f":第{i/10}个数据：[{degree},{msg.ranges[i]}]")
        
# 启动 ROS Spin 线程
def start_ros_node():
    rospy.spin()

# 打印数据
def start_ros2_node():
    while True:
        print(1)
        time.sleep(0.1)

if __name__ == '__main__':
    rospy.init_node("rplidar_node_client")
    lidar_sub = rospy.Subscriber("/scan",LaserScan,liadrCallback,queue_size=1000)

    thread1 = threading.Thread(target=start_ros_node)
    thread2 = threading.Thread(target=start_ros2_node)
    
    thread1.start()
    thread2.start()
    # while True:
    #     print(1)
    # rospy.spin()